﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using He.Common;
using He.Web.UI;

namespace He.Web.manage.member
{
    public partial class rank_list : Manage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                chkLoginLevel("viewmember");

                CookieHelper.Set("LastListUrl", Request.RawUrl);    //保存最后一次访问的列表页Url

                ShowInfo();
            }
        }

        #region 赋值操作
        private void ShowInfo()
        {
            BLL.member_rank bll = new BLL.member_rank();
            rptList.DataSource = bll.GetList("id>0");
            rptList.DataBind();
        }
        #endregion

        //删除
        protected void lbtnDel_Command(object sender, CommandEventArgs e)
        {
            chkLoginLevel("delmember");

            int id = Convert.ToInt32(e.CommandArgument);
            BLL.member_rank bll = new BLL.member_rank();
            Model.member_rank model = bll.GetModel(id);
            if (model.is_sys == 1)
            {
                ShowError("系统默认会员等级不可删除");
                return;
            }
            if (new BLL.member().ExistsMember(id))
            {
                ShowError("该等级下存在会员，不可删除");
                return;
            }
            //删除记录
            bll.Delete(id);
            //保存日志
            SaveLogs(string.Format("[会员等级管理]删除等级:{0}", model.title));
            ShowSuccess("会员等级删除成功啦！", Request.RawUrl);
        }
    }
}
